Sensu : Email Handler
2017/11/08 |
Set Email Handler to notify alerts via Email.
|
|
[1] |
Install SMTP Server, refer to here.
If using SMTP only on localhost, it's OK to run it with default settings. |
[2] | Install a plugin for Email. |
[root@dlp ~]#
sensu-install -p mailer
[root@dlp ~]#
vi /etc/sensu/conf.d/mailer.json # create new # for [admin_gui], it's Uchiwa's access path # if enabled SSL/TLS, set [smtp_enable_starttls_auto] to [true] { "mailer": { "admin_gui" : "https://dlp.srv.world:3000/", "mail_from": "root@dlp.srv.world", "mail_to": "root@dlp.srv.world", "smtp_address": "127.0.0.1", "smtp_enable_starttls_auto": "false", "smtp_port": "25", "smtp_domain": "srv.world" } }
[root@dlp ~]#
vi /etc/sensu/conf.d/default-handler.json # create new { "handlers": { "default": { "type": "set", "handlers": [ "mailer" ] }, "mailer": { "type": "pipe", "command": "handler-mailer.rb", "severities": [ "ok", "warning", "critical", "unknown" ] } } } systemctl restart sensu-server sensu-api |
[3] | It's OK. If some failure occurs or recovered, notify email is sent to the address you set on config. |
# follows is the case 22 port check is failure From root@dlp.srv.world Fri Nov 10 19:28:30 2017 Return-Path: <root@dlp.srv.world> X-Original-To: root@dlp.srv.world Delivered-To: root@dlp.srv.world Date: Fri, 10 Nov 2017 19:28:30 +0900 From: root@dlp.srv.world Reply-To: root@dlp.srv.world To: root@dlp.srv.world Subject: ALERT - dlp/port_check: CRITICAL Content-Type: text/plain; charset=ISO-8859-1 X-Sensu-Host: dlp X-Sensu-Timestamp: 2017-11-10 19:28:29 +0900 X-Sensu-Address: 127.0.0.1 X-Sensu-Check-Name: port_check X-Sensu-Status: CRITICAL X-Sensu-Occurrences: 1 Status: RO CheckPort CRITICAL: Connection refused by 0.0.0.0:22 Admin GUI: https://dlp.srv.world:3000/ Host: dlp Timestamp: 2017-11-10 19:28:29 +0900 Address: 127.0.0.1 Check Name: port_check Command: check-ports.rb -p <password omitted> -t 10 Status: CRITICAL Occurrences: 1 # for the case above failure has beec recovered From root@dlp.srv.world Fri Nov 10 19:29:30 2017 Return-Path: <root@dlp.srv.world> X-Original-To: root@dlp.srv.world Delivered-To: root@dlp.srv.world Date: Fri, 10 Nov 2017 19:29:30 +0900 From: root@dlp.srv.world Reply-To: root@dlp.srv.world To: root@dlp.srv.world Subject: RESOLVED - dlp/port_check: OK Content-Type: text/plain; charset=ISO-8859-1 X-Sensu-Host: dlp X-Sensu-Timestamp: 2017-11-10 19:29:29 +0900 X-Sensu-Address: 127.0.0.1 X-Sensu-Check-Name: port_check X-Sensu-Status: OK X-Sensu-Occurrences: 1 Status: RO CheckPort OK: All ports (22) are accessible for host 0.0.0.0 Admin GUI: https://dlp.srv.world:3000/ Host: dlp Timestamp: 2017-11-10 19:29:29 +0900 Address: 127.0.0.1 Check Name: port_check Command: check-ports.rb -p <password omitted> -t 10 Status: OK Occurrences: 1 |